package stbz_yc_sdk_golang

import (
	"context"
	"github.com/gogf/gf/util/gconv"
)

//设置访问apiurl
func (a *Client)SetApiUrl(ctx context.Context, apiUrl string) (client *Client) {
	a.apiUrl = apiUrl
	return a
}

//设置请求服务名称
func (a *Client)SetServerName(ctx context.Context, serverName string) (client *Client) {
	a.serverName = serverName//服务名称
	return a
}

//设置请求id
func (a *Client)SetRequestId(ctx context.Context, requestId string) (client *Client) {

	if ctx.Value("request_id") != nil {//设置请求id
		a.requestId = gconv.String(ctx.Value("request_id"))
		return a
	}

	if requestId != "" {//设置请求id
		a.requestId = requestId
		return a
	}
	return a
}

//设置日志路径
func (a *Client)SetLogPath(ctx context.Context, logPath string) (client *Client) {
	a.logPath = logPath
	return a
}

//获取访问apiurl
func (a *Client)GetApiUrl() string {
	return a.apiUrl
}

//获取访服务名称
func (a *Client)GetServerName() string {
	return a.serverName
}

//获取请求日志
func (a *Client)GetRequestId() string {
	if a.requestId != "" {
		return a.requestId
	}

	serverName := a.GetServerName()
	a.requestId = CreateIdentify(serverName)
	return a.requestId
}

//获取日志路径
func (a *Client)GetLogPath() string {
	if a.logPath == "" {
		a.logPath = "./logs/yc_server/"
	}
	return a.logPath
}